/* Copyright (c) 2025 LiuZiyao
*    Key Laboratory of Cyberspace Security Defense,Institute of Information Engineering, CAS
*    School of Cyber Security, University of Chinese Academy of Sciences     
*
* This file is part of the openHiTLS project.
*
* openHiTLS is licensed under the Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
*
*     http://license.coscl.org.cn/MulanPSL2
*
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/

#ifndef api_h
#define api_h

#include  "polarlac_param.h"
//  Set these three values apropriately for your algorithm
#define CRYPTO_SECRETKEYBYTES SK_LEN+PK_LEN
#define CRYPTO_PUBLICKEYBYTES PK_LEN
#define CRYPTO_BYTES MESSAGE_LEN
#define CRYPTO_SESSION HASHLEN
#define CRYPTO_CIPHERTEXTBYTES CIPHER_LEN

#define CRYPTO_SEEDBYTES SEED_LEN

// Change the algorithm name
#define CRYPTO_ALGNAME STRENGTH
//functions for pke
int crypto_encrypt_keypair( unsigned char *pk, unsigned char *sk);
int crypto_encrypt( unsigned char *c, unsigned long long *clen, const unsigned char *m, unsigned long long mlen, const unsigned char *pk, unsigned char *seeds);
int crypto_encrypt_open(unsigned char *m, unsigned long long *mlen,const unsigned char *c, unsigned long long clen,const unsigned char *sk);
//key generation
int kg(unsigned char *pk, unsigned char *sk);
//key generation with seed
int kg_seed(unsigned char *pk, unsigned char *sk, unsigned char *seed);
// encryption
int original_pke_enc(const unsigned char *pk, const unsigned char *m, unsigned long long mlen, unsigned char *c, unsigned long long *clen, unsigned char *seeds);
// encryption with seed
int original_pke_enc_seed(const unsigned char *pk, const unsigned char *m, unsigned long long mlen, unsigned char *c, unsigned long long *clen, unsigned char *seed);
// print the average cpucycles of polar_enc
int polar_enc_cpucycles();
// decrypt
int original_pke_dec(const unsigned char *sk, const unsigned char *c, unsigned long long clen, unsigned char *m, unsigned long long *mlen);
// print the average cpucycles of polar_dec
int polar_dec_cpucycles();

//functions for kem
int crypto_kem_keypair( unsigned char *pk, unsigned char *sk);
int crypto_kem_enc( unsigned char *ct, unsigned char *ss, const unsigned char *pk);
int crypto_kem_dec( unsigned char *ss, const unsigned char *ct, const unsigned char *sk);

int kem_enc_fo(const unsigned char *pk, unsigned char *k, unsigned char *c);
// fo encryption for cca security with seed
int kem_enc_fo_seed(const unsigned char *pk, unsigned char *k, unsigned char *c, unsigned char *seed);
// decrypt of fo mode
int kem_dec_fo(const unsigned char *pk, const unsigned char *sk, const  unsigned char *c, unsigned char *k);

#endif /* api_h */
